package org.chenwang.projects.ehcacheaws;

import java.util.Properties;

import net.sf.ehcache.event.CacheEventListener;
import net.sf.ehcache.event.CacheEventListenerFactory;

public class AmazonS3CacheReplicatorFactory extends CacheEventListenerFactory {

	@Override
	public CacheEventListener createCacheEventListener(Properties properties) {
		
		CacheEventListener listener = null;
		
		AmazonS3Configuration c = AmazonS3Configuration.parse(properties);
		
		if (c == null) {
			listener = null;
		}
		else {
			if (c.isMultithreaded()) {
				listener = new AmazonS3CacheReplicatorImplRestSimpleMulti(c.getBucketName(), c.getPathName(), c.getPathSeparator(), c.getCredentials());
			}
			else {
				listener = new AmazonS3CacheReplicatorImplRestSimple(c.getBucketName(), c.getPathName(), c.getPathSeparator(), c.getCredentials());
			}
		}
		
		return listener;
		
	}

}
